#include <xscript/xscriptexecutor.h>
#include <astree/xabstractasyntaxtreevariable.h>

XAbstractSyntaxTreeVariable::XAbstractSyntaxTreeVariable(XTokenPtr inputToken):
    XAbstractSyntaxTree(inputToken) {
    setName(inputToken->getString());
}

bool XAbstractSyntaxTreeVariable::invoke(std::shared_ptr<XVariableTable> table) {
    result = XItem::createFromToken(token);
    if (!result) {
        XScriptExecutor::getInstance()->setError(XError::XError_ArgumentTypeError, token->toString());
        return false;
    }
    return true;
}
